package com.woniu.controller;

import com.woniu.entity.RbacPerm;
import com.woniu.entity.ResponseEntity;
import com.woniu.service.RbacPermService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Rain
 * @Description :
 * @date 2022/09/03 10:23
 */
@RestController
@RequestMapping("/rbacPerm")
@CrossOrigin
public class RbacPermController {

    @Autowired
    RbacPermService service;

    @PostMapping("/{pageNum}/{pageSize}")
    public ResponseEntity findByCondition(@PathVariable int pageNum,
                                          @PathVariable int pageSize,
                                          @RequestBody RbacPerm searchObj) {

        return service.findByCondition(pageNum, pageSize, searchObj);
    }

    @GetMapping("/{id}")
    public ResponseEntity findOne(@PathVariable("id") int id) {
        return service.findOne(id);
    }

    @PostMapping("/")
    public ResponseEntity addOne(@RequestBody RbacPerm perm) {
        return service.addOne(perm);
    }

    @DeleteMapping("/{id}")
    public ResponseEntity deleteOne(@PathVariable("id") int id) {
        return service.deleteOne(id);
    }

    @PutMapping("/")
    public ResponseEntity updateOne(@RequestBody RbacPerm perm) {
        return service.updateOne(perm);
    }

    @PutMapping("/{id}/{status}")
    public ResponseEntity updatePermStatus(@PathVariable Integer id, @PathVariable String status) {
        return service.updatePermStatus(id, status);
    }


}
